package cn.edu.scau.cmi.tangqingning.entity;

import java.util.ArrayList;

public class Teacher {
	private int id;
	private String name;
	private ArrayList<Student> sList = new ArrayList<Student>(); 
	
	public Teacher(int id, String name) {
		this.setId(id);
		this.setName(name);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public ArrayList<Student> getSList() {
		return sList;
	}
	
	public Student ChooseStudent(int id) {
		int i;
		for(i = 0; i < sList.size(); i++) {
			if(id == sList.get(i).getId()) {
				return sList.get(i);
			}
		}
		return null;
	}
	
	public void updateStudent(int id, Student s) {
		int i = 0;
		for(; i < sList.size(); i++) {
			if(id == sList.get(i).getId()) {
				sList.get(i).UpdateTutor(null);
				s.UpdateTutor(this);
				sList.set(i, s);	
			}
		}
	}
}
